/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			pglayspc.h
  \date			Sep 2012
  \author		TNick

  \brief		Contains the definition for PgLaySpc class


*//*


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Please read COPYING and README files in root folder
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __PGLAYSPC_INC__
#define __PGLAYSPC_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<cpg/logic/pglayer.h>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

namespace	cpg		{


/**
*	@brief	The representation for the global layer
*
*	For an overview of the layers see \ref layers "dedicated page".
*/
class PgLaySpc		: public PgLayer		{
	BBM_TRACK( PgLaySpc );

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

private:

		/**
		*	@brief	associated space; if NULL, the layer is a global one
		*/
		PgSpace *			space_;


		/**
		*	@brief	PgItTree of items contained by this layer
		*/
		PgItTree			items_;



	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:


	/**
	*	@brief	constructor;
	*/
	PgLaySpc			( PgSpace * spc )
		: PgLayer()
	{ space_ = spc; }


	/**
	*	@brief	constructor; uses the layer as a template
	*/
	PgLaySpc			( PgSpace * spc, PgLayer * layer );


	/**
	*	@brief	constructor;
	*/
	PgLaySpc			( QString s_name, PgSpace * spc )
		: PgLayer()
	{
		space_ = spc;
		d_.s_name_ = s_name;
	}


	/**
	*	@brief	destructor;
	*/
	~PgLaySpc			( void );



	/**
	*	@brief	tell if this layer is global or associated with a space
	*/
	bool				isGlobal			( void ) const
	{ return false; }


	/**
	*	@brief	get associated document
	*/
	CpgDoc *				document			( void ) const;


	/**
	*	@brief	get associated space
	*/
	inline PgSpace *	space				( void ) const
	{ return space_; }


	/**
	*	@brief	get the PgItTree of items belonging to this layer
	*/
	PgItTree *			items				( PgSpace * spc )
	{ Q_UNUSED(spc); return &items_; }



	/**
	*	@brief	get the limits of the objects in this layer
	*/
	bool				extents				(
			ABOX2D &			r
			)
	{ return items_.boundingBox( r ); }


protected:


	/**
	*	@brief	add an item to internal PgItTree
	*
	*	Views are not updated.
	*/
	bool			addItem					( PgSpace * sp, PgItem * itm );


	/**
	*	@brief	remove an item from internal PgItTree
	*
	*	Views are not updated.
	*/
	bool			remItem					( PgSpace * sp, PgItem * itm )
	{
		Q_UNUSED( sp );
		return items_.removeOne( itm );
	}


	/**
	*	@brief	extract myself from the space's chain of layers
	*/
	void			forceExtractFromSpace	( void );


	/**
	*	@brief	insert myself in the space's chain of layers
	*/
	void			forceInsertInSpace		( void );


	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class PgLaySpc	*/

/*  CLASS    =============================================================== */
//
//
//
//

}	//	namespace	cpg

#endif // __PGLAYSPC_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
